//1231231
var s=new Set([1,2,3,4,5,6]);
var b=new Set([5,6,8,9,0]);


// for(var i of s){
//     console.log(i);
// }


// for(let i of s.values()){
//     console.log(i);
// }

//并集
// console.log([...new Set([...s,...b])]);

// //交集
// console.log([...s].filter(x=>b.has(x)));

// console.log([...s].filter(x=>!b.has(x)));


var m=new Map([[1,2],[3,4],[5]]);

console.log([...m]);


var m2=new Map();
m2.set("a","aa");
m2.set("b","bb");
console.log(m2.get('a'));
console.log(m2.has('b'));
console.log({...m2});

function changeMap(m){
    var obj=Object.create(null);
    m.forEach((v,i) => {
        obj[i]=v;
    });
    console.log(obj.a);
    return obj;
}


var m3=changeMap(m2);
var m4=new Map(Object.entries(m3));
console.log(m4);


async function async1() {
    console.log('async1 start');
    await async2();
    console.log('async1 end');
}
async function async2() {
    console.log('async2');
}
console.log('script start');
setTimeout(function() {
    console.log('setTimeout');
    new Promise(function(resolve) {
        console.log('promise3');
        setTimeout(function() { console.log('setTimeout2');},0);
        resolve();
    }).then(function() {
        console.log('promise4');
    });
}, 0)
async1();
new Promise(function(resolve) {
    console.log('promise1');
    resolve();
}).then(function() {
    console.log('promise2');
});
console.log('script end');

//script start
//async1 start
//async2
//promise1
//script end
//async1 end
//promise2
//setTimeout





var arr = [ [1, 2, 2], [3, 4, 5, 5], [6, 7, 8, 9, [11, 12, [12, 13, [14] ] ] ], 10];
[...new Set(arr.flat(Infinity))].sort((x,y)=>{ return x>y?1:-1});






//找数字
function binaryFind(arr,result,low=0,hight=arr.length-1){
    var n=Math.floor((low+hight)/2);
    console.log('二分数字位:'+arr[n]);
    if(arr[n]==result){
        console.log('找到啦,在第'+n+1+'位');
    }
    else if(arr[n]>result){
        return binaryFind(arr,result,low,n-1);
    }
    else if(arr[n]<result){
        return binaryFind(arr,result,n+1,hight);
    }
}
var binaryFindArr=[];
for(var i=1;i<101;i++){binaryFindArr.push(i)}
console.log('binaryFind',binaryFind(binaryFindArr,77));

